#ifndef _M6020_H
#define _M6020_H

#include "device.h"

typedef struct 
{
    int16_t angle;          //转子机械角度
    int16_t last_angle;
    int16_t prelas_angle;
    int16_t speed_count;
    int16_t voltage;        //实际电流
    int16_t speed;          //速度 根据角度差算
    uint32_t fdbktime;      //反馈时间
    uint32_t count;         //累计收包数
}M6020_FDBK_UNIT,*P_M6020_FDBK_UNIT;

typedef struct
{
    M6020_FDBK_UNIT m1;
    M6020_FDBK_UNIT m2;
    M6020_FDBK_UNIT m3;
    M6020_FDBK_UNIT m4;   
    M6020_FDBK_UNIT m5;
    M6020_FDBK_UNIT m6;
    M6020_FDBK_UNIT m7;
    M6020_FDBK_UNIT m8;
}M6020_FDBK,*P_M6020_FDBK;

typedef enum
{
    M6020_PACK_1_4,
    M6020_PACK_5_8,
}M6020_PACK;

typedef struct
{
    int16_t setvol[4];//8个电机的控制电压
    M6020_PACK pack;
}M6020_CTRL,*P_M6020_CTRL;


void m6020SetVoltage(P_M6020_CTRL pctrl, CAN_HandleTypeDef *hcan);
void m6020ResetFeedBack(P_M6020_FDBK pfdbk);
uint8_t m6020FeedBack(P_CAN_RX pcanrx,P_M6020_FDBK pfdbk);

#endif
